<?php
    
    $ra_id = $_GET['ra_id'];
    $sql = "SELECT ra_img FROM relate_article WHERE ra_id=$ra_id";
    $img_old = $db->Execute($sql);
    
    $sql = "DELETE FROM relate_article WHERE ra_id=$ra_id";
    $result = $db->Execute($sql);
    
    if($result){
        $msg = 'ลบข้อมูลเรียบร้อยแล้ว';
        if(file_exists(APPPATH.'/images/relate-article/'.$ra_id)){
            remove_dir(APPPATH.'/images/relate-article/'.$ra_id);
        }
    }else{
        $msg = 'ไม่สามารถลบข้อมูลได้';
    }
?>

<?php
    include('header.php');
?>
<div class="grid_24" id="contents">
    <div id="query_result">
    <?php
        echo $msg , ' <img src="images/ajax-loader.gif" />';
        redirect('?m=relate-article',3);
    ?>
    </div>
</div><!-- end .grid_18 -->
<div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>